<template>
	<view>
		<!-- #ifdef APP-PLUS -->
		<div style="height: 35px; background-color:#39A6FF;"></div>
		<!-- #endif -->
		<uni-nav-bar left-icon="left" background-color="#39A6FF" :border="false" @clickLeft="goback" color="#fff"
			title="意见反馈"></uni-nav-bar>


		<view class="formBox">
			<uni-forms ref="form" :modelValue="formData" :label-width='0' :rules="rules">
				<uni-forms-item label="" name="content">
					<uni-easyinput type="textarea" v-model="formData.content" placeholder="请输入你的意见" />
				</uni-forms-item>
			</uni-forms>
			<button type="primary" style="backgroundColor:#39A6FF; borderColor:#39A6FF;" @click="submitForm">提交</button>
		</view>
	</view>
</template>

<script>
	import {
		APIJS
	} from '../../api/api.js'
	export default {
		data() {
			return {
				formData: {
					content: ''
				},
				rules: {
					// 对name字段进行必填验证
					content: {
						rules: [{
							required: true,
							errorMessage: '请输入意见',
						}]
					}
				}
			}
		},
		methods: {
			goback() {
				uni.navigateBack({});
			},
			submitForm() {
				let vm = this
				this.$refs.form.validate().then(res => {

					APIJS.addFeedback({
						content: vm.formData.content,
						userPhone: uni.getStorageSync('phone')
					}).then(() => {
						vm.formData.content = ''
						uni.showToast({
							title: '反馈成功！',
							duration: 3000,
							icon: 'success'
						});
					})
				}).catch(err => {
					console.log('表单错误信息：', err);
				})
			}
		}

	}
</script>

<style lang="less" scoped>
	.formBox {
		padding: 15px 15px;
	}
</style>
